/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#pragma once

#include <baja/common.hpp>
#include <baja/stream/stream_fwd.hpp>
#include <baja/stream/stream_types.hpp>

namespace baja {

struct istream : public ibase
{
    BAJA_INTERFACE(istream, "620F81A7-A59C-43A2-B199-3CBCD36BB0D3")

    virtual size_t read(void* buffer, const size_t bytesToReadd) = 0;
    virtual size_t write(const void* buffer, const size_t bytesToWrite) = 0;
    virtual size_t seek(const long long offset, const stream_origin origin) = 0;
    virtual void setSize(const size_t size) = 0;
    virtual size_t getSize() = 0;
    virtual void copyTo(const std::shared_ptr<istream>& s, const size_t cb, size_t* cbRead, size_t* cbWritten) = 0;
    virtual void commit(const uint32 flags) = 0;
    virtual void revert() = 0;
    virtual void lockRegion(const size_t offset, const size_t cb, const uint32 lockType) = 0;
    virtual void unlockRegion(const size_t offset, const size_t cb, const uint32 lockType) = 0;
};

struct imemory_stream : public istream
{
    BAJA_INTERFACE(imemory_stream, "735597ed-0e9b-4173-8586-d27f6b685f0d")

    virtual void* getBuffer() = 0;
    virtual size_t getBufferSize() = 0;
    virtual size_t getBufferPos() = 0;
	virtual const std::vector<byte>& getBytes() = 0;
};

} // namespace baja